﻿var PUB = {
    isLogin: false,
    actionUrl: "http://www.pomoho.com/api/userapi.asmx/UserLogin",
    Init: function (a) {
        baseurl = "http://video.pomoho.com/do";
        var b = this.cookie("LoginInfo");
        if (b) {
            b = unescape(b);
            b = b.split("$***$");
            login_user = {
                uid: b[0].replace("LoginInfo=", ""),
                nick: b[1],
                spacename: unescape(b[2]),
                spaceURL: b[3],
                newmsg: 2
            };
            PUB.isLogin = true;
            typeof a != "undefined" && a(login_user)
        } else {
            PUB.isLogin = false;
            typeof a != "undefined" && a(null)
        }
        if ("undefined" == typeof a || a) PUB.isLogin ? this.logined() : this.unlogin();
        PUB.loadScript("http://live.pomoho.com/getxmldata.aspx?type=2&ids=" + flvid + "_999");
        PUB.commentReply("#Comment");
        PUB.emotionWRS("#Comment");
        PUB.emotions()
    },
    ajaxLoad: function (a, b, c, d, e, f) {
        $.ajax({
            type: a,
            url: b,
            data: c,
            dataType: d,
            beforeSend: function () {
                typeof e != "undefined" && e.length > 0 && $(e).show()
            },
            complete: function () {
                typeof e != "undefined" && e.length > 0 && $(e).hide()
            },
            success: function (h) {
                _getDATA = h;
                f.call(this)
            }
        })
    },
    loadCss: function (a) {
        var d = document.createElement("link");
        d.type = "text/css";
        d.rel = "stylesheet";
        d.href = a;
        $("head")[0].appendChild(d)
    },
    loadScript: function (a, b) {
        var c = {
            random: true
        };
        http: b && $.extend(c, b);
        var d = document.createElement("script");
        d.type = "text/javascript";
        var e = new Date;
        if (c.random) a = a.match(/.*\?./) ? a + "&random=" + e.getTime() + parseInt(Math.random() * 1E4) : a + "?random=" + e.getTime() + parseInt(Math.random() * 1E4);
        d.src = a;
        $("head")[0].appendChild(d)
    },
    unlogin: function () {
        var a = "";
        a += '<div class="row" id="topNav">';
        a += '<a title="\u767b\u5f55" href="http://b.pomoho.com/" target="_blank" >\u767b\u5f55</a>';
        a += '<a title="\u6ce8\u518c" href="http://b.pomoho.com/" target="_blank">\u6ce8\u518c</a>';
        a += "</div>";
        $("#top_Nav #L").html(a)
    },
    localTime: function () {
        var a = new Date,
        b = a.getHours();
        a = $.browser.msie ? String(a).split(" ")[3].substr(0, 5) : String(a).split(" ")[4].substr(0, 5);
        switch (b) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                a = "\u65e9\u4e0a\u597d";
                break;
            case 8:
            case 9:
            case 10:
            case 11:
                a = "\u4e0a\u5348\u597d";
                break;
            case 12:
                a = "\u4e2d\u5348\u597d";
                break;
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
                a = "\u4e0b\u5348\u597d";
                break;
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
                a = "\u665a\u4e0a\u597d"
        }
        return a
    },
    videolink: function (a) {
        if (PUB.isLogin) {
            var b = {
                imdbid: a,
                userID: login_user.uid
            };
            $.ajax({
                type: "get",
                url: "http://www.pomoho.com/api/userapi.asmx/VideoLinks",
                data: b,
                dataType: "jsonp",
                jsonp: "jsoncallback",
                timeout: 300000,
                success: function (e) {
                    if (e.Result == '-2') {
                        Pui.header.loginfo2()
                    } else {
                        alert(e.Msg)
                    }
                }
            })
        }
    },
    logined: function () {
        var a = this.localTime(),
        b = "";
        b += '<div class="row" id="topNav">';
        b += '<span class="welcome"><span class="time">' + a + '\uff0c</span><a class="user" target="_blank" href="http://home.pomoho.com/' + login_user.spaceURL + '.shtml" title="' + login_user.nick + '" >' + PUB.SetString(login_user.nick, 10) + "</a></span>";
        b += '<span class="s"><a class="count" title="\u4f60\u7684\u5e10\u6237" href="http://b.pomoho.com/manage/index.aspx" target="_blank" >\u5e10\u6237</a>';
        b += ' <div class="dbd s3">';
        b += " <ul>";
        b += ' <li><a class="d_item" title="\u6211\u7684\u89c6\u9891" href="http://b.pomoho.com/manage/managevideo.aspx" target="_blank" >\u6211\u7684\u89c6\u9891</a></li>';
        b += ' <li><a class="d_item" title="\u6211\u7684\u8ba2\u9605" href="http://b.pomoho.com/manage/subscribevblog.aspx" target="_blank" >\u6211\u7684\u8ba2\u9605</a></li>';
        b += ' <li><a class="d_item" title="\u6211\u7684\u6536\u85cf" href="http://b.pomoho.com/manage/managevideo.aspx?type=favs" target="_blank" >\u6211\u7684\u6536\u85cf</a></li>';
        b += ' <li><a class="d_item" title="\u6211\u7684\u76f8\u518c" href="http://b.pomoho.com/manage/managealbum.aspx" target="_blank" >\u6211\u7684\u76f8\u518c</a></li>';
        b += " </ul>";
        b += ' <div class="m1"><a title="\u66f4\u591a\u7ba1\u7406" href="http://b.pomoho.com/manage/index.aspx" target="_blank" >\u66f4\u591a..&nbsp;&nbsp;</a></div>';
        b += " </div>";
        b += " </span>";
        b += ' <a title="\u9000\u51fa\u767b\u5f55" href="http://b.pomoho.com/ui/logout.aspx?AfterLoginReturnURL=' + window.location + '">\u9000\u51fa</a>';
        b += "</div>";
        $("#L").removeClass().html(b);
        this.SH()
    },
    SetString: function (a, b) {
        if (typeof a == "undefined") return "";
        for (var c = 0,
        d = "",
        e = 0; e < a.length; e++) {
            if (a.charCodeAt(e) > 128) c += 2;
            else c++;
            d += a.charAt(e);
            if (c >= b) break
        }
        return d
    },
    SH: function () {
        var a;
        $("#top_Nav #L .s").hover(function () {
            $(this).siblings().find(".dbd").hide();
            $(this).find(".dbd").show();
            clearTimeout(a)
        },
        function () {
            var b = setTimeout;
            $("#top_Nav #L .s").find(".dbd").slideUp("slow");
            a = b(void 0, 500)
        })
    },
    closeDiv: function () {
        if ($.browser.msie && String($("body").attr("id")) == "B-Upload") Pra.ui.overlay();
        else String($("body").attr("id")) == "B-Upload" ? $("#zhezhao").remove() : $("#zhezhao").hide();
        $("#Prompt").hide();
        return false
    },
    pos: function () {
        return {
            elementTop: function (a) {
                for (var b = 0,
                c = a; c; c = c.offsetParent) b += c.offsetTop;
                for (c = a.parentNode; c && c != document.body; c = c.parentNode) if (c.scrollTop) b -= c.scrollTop;
                return b
            }
        }
    } (),
    gettime: function () {
        var a = new Date,
        b = $.browser.msie ? a.getYear() : String(a).split(" ")[3],
        c = $.browser.msie ? String(a).split(" ")[3].substr(0, 5) : String(a).split(" ")[4].substr(0, 5);
        return b + "-" + parseInt(a.getMonth() + 1) + "-" + a.getDate() + " " + c
    },
    cookie: function (a, b, c) {
        if (typeof b != "undefined") {
            c = c || {};
            if (b === null) {
                b = "";
                c.expires = -1
            }
            var d = "";
            if (c.expires && (typeof c.expires == "number" || c.expires.toUTCString)) {
                if (typeof c.expires == "number") {
                    d = new Date;
                    d.setTime(d.getTime() + c.expires * 24 * 60 * 60 * 1E3)
                } else d = c.expires;
                d = "; expires=" + d.toUTCString()
            }
            var e = c.path ? "; path=" + c.path : ";path=/",
            f = c.domain ? "; domain=" + c.domain : "";
            c = c.secure ? "; secure" : "";
            document.cookie = [a, "=", escape(b), d, e, f, c].join("")
        } else {
            b = null;
            if (document.cookie && document.cookie != "") {
                c = document.cookie.split(";");
                for (d = 0; d < c.length; d++) {
                    e = jQuery.trim(c[d]);
                    if (e.substring(0, a.length + 1) == a + "=") {
                        b = unescape(e.substring(a.length + 1));
                        break
                    }
                }
            }
            return b
        }
    },
    GetAction: function (a) {
        if (PUB.isLogin) {
            var b = {
                userID: login_user.uid,
                objType: 2,
                objID: a,
                nickName: login_user.nick,
                spaceUrl: login_user.spaceURL,
                objName: videoTitle,
                objImgUrl: pic,
                objIntro: encodeURI($('.v_intro').html()),
                objLinkUrl: window.location.href,
                cacheType: 2
            };
            $.ajax({
                type: "get",
                url: "http://www.pomoho.com/api/userapi.asmx/GetAction",
                data: b,
                dataType: "jsonp",
                jsonp: "jsoncallback",
                timeout: 300000,
                success: function (e) { }
            })
        }
    },
    GetValidCodeImg: function () {
        ValidCodeURL = baseurl + "/video/ValidCode.aspx?type=1";
        document.getElementById("Comment") ? document.getElementById("validcode").src = ValidCodeURL + "&objid=" + flvid + "&ran=" + Math.random() : document.getElementById("validcode").src = ValidCodeURL + "&objid=" + _space_user.uid + "&ran=" + Math.random()
    },
    CodeImgLoader: function () {
        $("#tb_validcode").after('<a href="javascript:PUB.GetValidCodeImg();" title="\u770b\u4e0d\u6e05\u695a\uff1f\u8bf7\u70b9\u51fb\u5237\u65b0\u9a8c\u8bc1\u7801\uff01" style="position:relative;top:6px;*top:4px;" ><img id="validcode" border=0 width="60" height="20" src="" /></a>').removeAttr("onfocus");
        $("#post_content").unbind("focus");
        $("#post_content").click(function () {
            if ($("#QuickComment").length > 0) {
                $(".f_v").hide();
                $("#QuickComment").hide()
            }
        });
        this.GetValidCodeImg()
    },
    SetValidCodeImg: function (a) {
        var d = document.getElementById('tb_validcode');
        if (d == null) {
            var b = "";
            b = '\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801&nbsp;&nbsp;<input id="tb_validcode" type="text" onfocus="javascript:PUB.CodeImgLoader();" style="width:60px; border:1px #7B9EBD solid;margin:0 5px 0 0;" />';
            var c = $(a + " .commentAdd .form .submit").html();
            $(a + " .commentAdd .form .submit").html(b + c)
        }
    },
    SendCallBack: function (a, b) {
        a == 0 && alert("\u60a8\u7684\u9a8c\u8bc1\u7801\u9519\u8bef\uff01");
        a == -1 && alert("\u60a8\u7684\u9a8c\u8bc1\u7801\u5df2\u5931\u6548\u3002\u8bf7\u70b9\u51fb\u9a8c\u8bc1\u7801\u56fe\u7247\uff0c\u91cd\u65b0\u83b7\u53d6\u9a8c\u8bc1\u7801\uff01");
        setTimeout("$('#Comment .mDocument').eq(0).remove();", 1E3);
        if ($("#Comment .cl").length > 1) {
            $("#Comment .cl").eq(0).remove();
            $("#Comment h3").eq(0).remove()
        }
        setTimeout("textarea.attr('value', '" + b + "').focus();", 1E3);
        setTimeout(function () {
            var c = $("#CM h3 .title span").text() ? $("#CM h3 .title span").text() : 0;
            c = parseInt(c);
            var d = $.trim($("title").html());
            d = "http://video.pomoho.com/review.aspx?flvid=" + flvid + "&icount=" + (c - 1) + "&title=" + d + "&uid=" + _space_user.uid;
            $("#Comment h3 .title span").text(c - 1).parents("h3").find(".more a").attr("href", d)
        },
        1500)
    },
    commentReplyFill: function () {
        var a = textarea.val().replace(/\[em(\d+)\]/g, "<img src='http://static.pomoho.com/images/em/em$1.gif' />"),
        b = PUB.isLogin ? '<a href="javascript:;">' + login_user.spacename + "</a>" : "\u6e38\u5ba2",
        c = "",
        d = $("#Comment .cl").length,
        e = $("#CM h3 .title span").html() ? $("#CM h3 .title span").html() + 1 : 0;
        e = parseInt(e);
        $.trim($("title").html());
        if (d) {
            c += '<div class="mDocument" style="_width:100%;">';
            c += ' <div class="photo"><img src="http://static.pomoho.com/static/images/photo_68.gif" alt="" /></div>';
            c += ' <div class="detail">';
            c += ' <span class="n_user">' + b + "</span>";
            c += ' <p class="text">' + a + "</p>";
            c += " </div>";
            c += ' <div class="handle">';
            c += ' <span class="t_release">' + PUB.gettime() + "</span>";
            c += " </div>";
            c += "</div>";
            $("#Comment .cl").prepend(c).fadeTo("slow", 1)
        } else {
            c += '<h3><span class="title">\u7f51\u53cb\u8bc4\u8bba\uff08\u5171<span>' + (e + 1) + '</span>\u6761\uff09</span><span class="more"></span></h3>';
            c += '<div class="cl showblock"><div class="mDocument">';
            c += ' <div class="photo"><img src="http://static.pomoho.com/static/images/photo_68.gif" alt="" /></div>';
            c += ' <div class="detail">';
            c += ' <span class="n_user">' + b + "</span>";
            c += ' <p class="text">' + a + "</p>";
            c += " </div>";
            c += ' <div class="handle">';
            c += ' <span class="t_release">' + PUB.gettime() + "</span>";
            c += " </div>";
            c += "</div></div>";
            $("#Comment").prepend(c).fadeTo("slow", 1)
        }
        textarea.attr("value", "").focus()
    },
    doingReply: function () {
        var a = null;
        $("#Doing input[type=submit]").click(function () {
            var b = $.trim($("#Doing textarea").val());
            if (b == null) {
                alert("\u8bb0\u4e8b\u5185\u5bb9\u4e0d\u53ef\u4e3a\u7a7a\uff01");
                $("#Doing textarea").focus()
            } else {
                if (a != null) {
                    var c = new Date;
                    if (Date.parse(c.toUTCString()) - 6E4 < a) {
                        alert("\u7559\u8a00\u95f4\u9694\u4e0d\u5f97\u5c11\u4e8e1\u5206\u949f\uff01");
                        $("#Doing textarea").focus();
                        return
                    }
                } else {
                    c = new Date;
                    a = Date.parse(c.toUTCString())
                }
                c = PUB.pos.elementTop($("#Doing")[0]);
                window.scrollTo(0, c - 30);
                this.blur();
                setTimeout("PUB.doingReplyFill()", 1E3);
                b = escape(b.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace("'", "\u2018"));
                PUB.loadScript(baseurl + "/space/mydoingajax.aspx?opreatetype=add&writecontent=" + b + "&userid=" + _space_user.uid, {
                    random: false
                });
                return false
            }
        })
    },
    doingReplyFill: function () {
        var a = "<li><div>" + $.trim($("#Doing textarea").val()) + '</div><p>\u4e66\u5199\u4e8e<span>\u73b0\u5728</span><a href="javascript:;" onclick="$(this).parent().parent().hide()" class="is_login" title="\u5220\u9664">\u5220</a></p></li>';
        $("#Doing .nl")[0] || $("#Doing h2").after('<div class="nl detail"></div>');
        $(a).prependTo("#Doing .nl");
        $("#Doing textarea").attr("value", "").focus()
    },
    commentLoad: function () {
        var a = "innerHeight" in window ? window.innerHeight : document.documentElement.offsetHeight,
        b = $("#Comment")[0].offsetTop + 100;
        setTimeout(function () {
            var c = parseInt($("#video_" + flvid + "_999").find(".c_review span").html() == '' ? '0' : $("#video_" + flvid + "_999").find(".c_review span").html());
            if (b < a && c > 0) PUB.ajaxLoad("GET", "http://home.pomoho.com/do/interfaces/getvideoreview.aspx", "videoid=" + flvid + "&r=" + Math.random(), "html", "",
            function () {
                $("#Comment").prepend(_getDATA)
            });
            else b >= a && c >= 0 &&
            function d() {
                document.documentElement.scrollTop + a >= b ? PUB.ajaxLoad("GET", "http://home.pomoho.com/do/interfaces/getvideoreview.aspx", "videoid=" + flvid + "&r=" + Math.random(), "html", "",
                function () {
                    $("#Comment").prepend(_getDATA)
                }) : setTimeout(function () {
                    d()
                },
                2E3)
            } ()
        },
        5E3)
    },
    commentReply: function (a) {
        this.SetValidCodeImg(a);
        var b = this;
        $("#post_content").bind("focus",
        function () {
            b.CodeImgLoader()
        });
        $(a + " input[type=submit]").click(function () {
            textarea = $(a + " textarea");
            if ($.trim(textarea.val()) == "") {
                alert("\u7559\u8a00\u5185\u5bb9\u4e0d\u53ef\u4e3a\u7a7a\uff01");
                textarea.focus()
            } else {
                var c = "";
                if (document.getElementById("tb_validcode") != null) {
                    c = document.getElementById("tb_validcode").value;
                    if ($.trim(c) == "") {
                        alert("\u9a8c\u8bc1\u7801\u4e0d\u53ef\u4e3a\u7a7a\uff01");
                        return
                    }
                }
                var d = textarea.val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@--\>");
                switch (a) {
                    case "#Comment":
                        PUB.loadScript(baseurl + "/video/dealajaxdata.aspx?itype=1&imdbid=" + flvid + "&content=" + escape(d) + "&validcode=" + c, {
                            random: true
                        });
                        break;
                    case "#GuestBook":
                        PUB.loadScript(baseurl + "/space/personjs.aspx?dotype=4&userid=" + _space_user.uid + "&content=" + escape(d) + "&validcode=" + c, {
                            random: true
                        })
                }
                c = PUB.pos.elementTop(document.getElementById(a.slice(1)));
                window.scrollTo(0, c - 30);
                this.blur();
                setTimeout("PUB.commentReplyFill()", 1E3);
                b.GetValidCodeImg();
                return false
            }
        })
    },
    commentJudge: function () {
        var a = document.getElementById("tb_validcode").value;
        if (document.getElementById("Comment")) {
            var b = $("#Comment textarea").val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@--\>");
            PUB.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=1&imdbid=" + flvid + "&content=" + escape(b) + "&validcode=" + a, {
                random: true
            })
        } else if (document.getElementById("GuestBook")) {
            b = $("#GuestBook textarea").val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@--\>");
            PUB.loadScript(baseurl + "/space/personjs.aspx?dotype=4&userid=" + _space_user.uid + "&content=" + escape(b) + "&validcode=" + a, {
                random: true
            })
        }
        setTimeout("PUB.commentReplyFill()", 1E3);
        PUB.GetValidCodeImg();
        PUB.closeDiv()
    },
    emotions: function (a) {
        var b = 1;
        $(a + " .emotions").find(".l").click(function () {
            if (b >= 2) {
                $("#emotion_Box").animate({
                    left: -(572 * (b - 2))
                },
                1E3);
                if (b == 2) $(a + " .l").removeClass("l_b").attr("title", "\u5de6\u8fb9\u6ca1\u6709\u4e86");
                else b == 3 && $(a + " .r").addClass("r_b").attr("title", "\u5411\u53f3\u7ffb");
                b--
            }
            this.blur();
            return false
        }).end().find(".r").click(function () {
            if (b <= 2) {
                $("#emotion_Box").animate({
                    left: -(572 * b)
                },
                1E3);
                if (b == 1) $(a + " .l").addClass("l_b").attr("title", "\u5411\u5de6\u7ffb");
                else b == 2 && $(a + " .r").removeClass("r_b").attr("title", "\u53f3\u8fb9\u6ca1\u6709\u4e86");
                b++
            }
            this.blur();
            return false
        }).end().find("div a").each(function () {
            $(this).click(function () {
                var c = $(a + " textarea").val() + $(this).find("img").attr("src").replace(/.+\/(em\d+)\.gif/g, "[$1]");
                $(a + " textarea").val(c);
                return false
            })
        })
    },
    emotionWRS: function (a) {
        var b = "";
        b += '<div style="position:relative;width:572px;height:60px;overflow:hidden;margin:5px auto;"><div id="emotion_Box" style="position:absolute;left:0;top:0;width:4800px;">';
        for (var c = ["\u9ed1\u661f\u6253", "\u5927", "\u6ce1", "\u8e66", "\u7ee7\u7eed", "\u72c2", "\u9ed1\u661f\u6bb4", "\u5439", "\u6345", "\u88ab\u6bb4", "\u98de", "\u5618", "\u8d56", "\u9876", "\u53d8", "\u6eda\u7403", "\u751f", "\u819c\u62dc", "\u8f6c", "\u53e3", "KI", "\u9b3c", "\u6293\u72c2", "\u626f", "\u6d41", "\u95ed\u5634", "HI", "\u53ef\u7231", "\u6447", "\u8eb2", "\u591a", "\u5409"], d = 1; d <= 3; d++) {
            b += '<div style="width:572px;float:left;text-align:center;">';
            for (var e = (d - 1) * 11 + 1; e <= d * 11; e++) if (e <= 32) b += '<a href="" title="' + c[e - 1] + '" style="margin:0 1px;"><img src="http://static.pomoho.com/images/em/em' + e + '.gif" height="50" width="50" /></a>';
            b += "</div>"
        }
        b += "</div></div>";
        b += '<a href="" class="l" title="\u5de6\u8fb9\u6ca1\u6709\u4e86">\u5411\u5de6\u7ffb</a><a href="" class="r r_b" title="\u5411\u53f3\u7ffb">\u5411\u53f3\u7ffb</a>';
        $(b).appendTo($(".emotions"));
        this.emotions(a);
        this.commentLoad()
    }
};
Pui = {};
Pui.EXC = function (e) {
    var a = window.event || e;
    if (a.keyCode == 27) Pui.header.closeDiv()
};
Pui.callback = function (a) {
    if (a.indexOf("\u60A8\u8FD8\u672A\u767B\u5F55") != -1) {
        Pui.header.loginfo2()
    } else {
        alert(a)
    }
};
Pui.submitF = function (e) {
    var a = window.event || e;
    if (a.keyCode == 13) $("#btnlog").click()
};
Pui.header = {
    logDiv: function (a, b, c, d) {
        var e = '';
        if ($.browser.msie && String($('body').attr('id')) == 'B-Upload') {
            e += ''
        } else {
            e += '<div id="zhezhao"></div>'
        }
        e += ' <div id="Prompt" class="prompt">';
        e += ' <div class="k log_v">';
        e += ' <div class="meat">';
        e += ' <div class="close"><a title="关闭"></a></div>';
        e += ' <h3></h3>';
        e += ' <p class="p2">您的账号: ';
        e += ' <input id="uidName" type="text" onkeypress="Pui.submitF(event)" />';
        e += ' </p>';
        e += ' <p class="p2">登陆密码: ';
        e += ' <input id="uidPwd" type="password" onkeypress="Pui.submitF(event)" />';
        e += ' <a href="http://b.pomoho.com/ui/findpassword.aspx" target="_blank">忘记密码</a></p>';
        e += ' <p class="pbt">';
        e += ' <input id="btnlog" class="log" type="submit" value="登陆" />';
        e += ' <input id="reg" class="log" type="button" value="注册" />';
        e += ' </p>';
        e += ' </div>';
        e += ' </div>';
        e += ' </div>';
        $("body").prepend(e);
        if ($.browser.msie && String($('body').attr('id')) == 'B-Upload') {
            Pra.ui.overlay()
        } else { }
        $("#Prompt .close a").bind("click", Pui.header.closeDiv);
        $("#btnlog").click(function () {
            Pui.header.login(a, b, c, d)
        });
        $("#reg").click(function () {
            window.open('http://b.pomoho.com/ui/reg_v2.aspx')
        })
    },
    showLogDiv: function (a, b, c, d) {
        if (String($('body').attr('id')) == 'B-Upload') {
            this.logDiv(a, b, c, d)
        } else if (!$("#Prompt").length) {
            this.logDiv(a, b, c, d)
        }
        var e = document;
        var f = e.documentElement;
        var g = f.clientHeight;
        var i = f.scrollHeight > g ? f.scrollHeight : g;
        var j = f.scrollTop >= 0 ? (f.scrollTop + g / 2) : g;
        var h = j - $("#Prompt").height() / 2;
        var w = f.clientWidth / 2 - $("#Prompt").width() / 2;
        $("#zhezhao").height(i).show();
        $("#Prompt").css({
            top: h,
            left: w
        })
    },
    loginfo: function (a, b, c, d) {
        this.showLogDiv(a, b, c, d);
        $("#Prompt").show();
        $("#Prompt .k")[0].className = "k log_v";
        $('#uidName').focus();
        if (document.attachEvent) {
            document.attachEvent('onkeyup', Pui.EXC)
        } else {
            document.addEventListener('keyup', Pui.EXC, false)
        }
    },
    loginfo2: function (a, b, c, d) {
        this.loginfo(b, c, d, a)
    },
    loginfo2_callback: function (a) {
        window.location.href = "http://b.pomoho.com/manage/index.aspx"
    },
    unlogin: function () {
        var a = '';
        a += '<div class="row" id="topNav">';
        a += '<a title="登录" href="javascript:Pui.header.loginfo2(Pui.header.loginfo2_callback)">登录</a>';
        a += '<a title="注册" href="http://b.pomoho.com/ui/reg_v2.aspx" target="_blank">注册</a>';
        if (document.location.host.toString().indexOf('home.pomoho.com') != -1) {
            a += '<a target="_blank" href="http://bbs.pomoho.com">论坛</a>'
        } else {
            a += '<a href="http://www.pomoho.com/upload/" target="_blank" title="上传视频">上传视频</a>'
        }
        a += '</div>';
        $("#top_Nav #L").html(a)
    },
    SetString: function (a, b) {
        var c = 0;
        var s = "";
        for (var i = 0; i < a.length; i++) {
            if (a.charCodeAt(i) > 128) c += 2;
            else c++;
            s += a.charAt(i);
            if (c >= b) return s
        }
        return s
    },
    SH: function () {
        var a;
        $("#top_Nav #L .s").hover(function () {
            $(this).siblings().find(".dbd").hide();
            $(this).find(".dbd").show();
            clearTimeout(a)
        },
        function () {
            a = setTimeout(overDiv, 500);
            function overDiv() {
                $(this).find(".dbd").slideUp()
            }
        })
    },
    login: function (a, b, c, d) {
        var e = $.trim($("#uidName").val());
        var f = $("#uidPwd").val();
        if (e == '' || f == '') {
            alert("用户名或者密码不能为空")
        } else {
            if (a || c) {
                Pui.header.ui.logDiagAjax(e, f, a, b, c, d)
            } else {
                Pui.header.logAjax(e, f, d)
            }
        }
    },
    closeDiv: function () {
        if ($.browser.msie && String($('body').attr('id')) == 'B-Upload') {
            Pra.ui.overlay()
        } else if (String($('body').attr('id')) == 'B-Upload') {
            $("#zhezhao").remove()
        } else {
            $("#zhezhao").hide()
        }
        $("#Prompt").hide();
        return false
    },
    ui: function () {
        return {
            logDiag: function (a, b, c) {
                if (_is_login) {
                    if (a == 'new') {
                        window.open(b)
                    } else {
                        window.location.href = b
                    }
                } else {
                    Pui.header_v2.loginfo(a, b, c)
                }
            }
        }
    },
    logAjax: function (b, c, d) {
        var e = window.location.hostname;
        var f = window.location.toString().toLowerCase();
        var g = {
            userName: b,
            password: c
        };
        $.ajax({
            type: "get",
            url: "http://www.pomoho.com/api/userapi.asmx/UserLogin",
            data: g,
            dataType: "jsonp",
            jsonp: "jsoncallback",
            timeout: 300000,
            success: function (a) {
                switch (parseInt(a.Result)) {
                    case -1: alert("登录帐号不存在");
                        break;
                    case -2: alert("用户名或者密码错误,请重试");
                        break;
                    case 1:
                        PUB.cookie('UserInfo', a.UserInfo, {
                            path: '/',
                            domain: '.pomoho.com',
                            expires: 1 / 6
                        });
                        PUB.cookie('UserInfo', a.UserInfo, {
                            path: '/',
                            domain: '.pomoho.com',
                            expires: 1 / 6
                        });
                        PUB.isLogin = true;
                        PUB.videolink(flvid);
                        PUB.Init();
                        Pui.header.closeDiv();
                        break;
                    default:
                        alert("系统错误,请重试");
                        Pui.header.closeDiv()
                }
            }
        })
    }
};
Pui.showData = function (a) {
    var b = {
        user: [".t_login span", ".c_friend span", ".c_fans span", ".c_view span", ".c_video span", ".c_flower span"],
        video: [".c_view span", ".c_review span", ".c_bookmark span"],
        special: [".c_video span", ".c_view span", ".c_rss span", ".t_update span", ".t_length span"],
        combo: [".d_video span", ".d_collect span", ".d_topic span", ".d_menber span", ".d_album span", ".d_mvvideo span"],
        combo_handle: [".c_num", ".c_num_m"]
    },
    c = {
        user: [".d_time_login span", ".d_friend span", ".d_fans span", ".d_view span", ".d_video span", ".d_flower span"],
        video: [".d_view span", ".d_review span", ".d_bookmark span"],
        special: [".d_video span", ".d_view span", ".d_rss span", ".d_update span", ".d_length span"],
        combo: [".d_video span", ".d_collect span", ".d_topic span", ".d_menber span", ".d_album span", ".d_mvvideo span"]
    };
    $(".t_login").html("\u6700\u8fd1\u767b\u5f55\uff1a<span></span>");
    for (var d = 0,
    e = a.length; d < e; d++) {
        var f = a[d].type,
        h = a[d].data,
        n = "#" + f + "_" + a[d].id;
        if ($(n)[0]) for (j = 0; j < b[f].length; j++) if ($(n + " " + b[f][j])[0]) if (b[f][j] != b.video[0]) $(n + " " + b[f][j])[0].innerHTML = h[j];
        else $(n + " li.c_view").remove();
        else if ($(n + " " + c[f][j])[0]) $(n + " " + c[f][j])[0].innerHTML = h[j]
    }
};
Pui.video = {
    quote: function (a) {
        a = document.getElementById("re_q_" + a).value;
        document.getElementById("Textarea1").value = "[quote]" + a + "[/quote]" + document.getElementById("Textarea1").value;
        document.getElementById("Textarea1").focus()
    },
    delblog: function () { }
};
Pui.space = {
    init: function () {
        this.VideoWelter();
        this.gotoLink();
        this.hotVideoList();
        Pui.space.relateKeyCallback();
        this.zz();
        this.collect()
    },
    collect: function () {
        $("#VideoPlayer #Handle").find('.s1[title="\u8f6c\u8f7d\u8be5\u89c6\u9891"]').attr("href", "javascript:;");
        $("#VideoPlayer #Handle").find('.s1[title="\u8f6c\u8f7d\u8be5\u89c6\u9891"]').bind("click",
        function () {
            if (PUB.isLogin) PUB.videolink(flvid);
            else Pui.header.loginfo2()
        })
    },
    share: function (a, b, c) {
        a = "http://tieba.baidu.com/i/sys/share?link=" + a + "&type=video&title=" + b + "&content=" + c;
        if (!window.open(a, "itieba", "toolbar=0,resizable=1,scrollbars=yes,status=1,width=626,height=436")) location.href = a
    },
    gotoLink: function () {
        var a = encodeURIComponent($("title").html().replace(/(^\s*)|(\s*$)/g, "")),
        b = encodeURIComponent("http://home.pomoho.com/" + _space_user.username + "/" + flvid),
        c = encodeURIComponent("http://video.pomoho.com/swf/out_player.swf?flvid=" + flvid),
        d = encodeURIComponent("http://video.pomoho.com/swf/out_player.swf?flvid=" + flvid + "&qudao=tieba"),
        e = encodeURIComponent("http://video.pomoho.com/swf/out_player.swf?flvid=" + flvid + "&outall=true&qudao=51com"),
        f = encodeURIComponent("http://video.pomoho.com/swf/out_player.swf?flvid=" + flvid + "&qudao=msn"),
        y = encodeURIComponent("http://resources.pomoho.com/swf/out_player.swf?flvid=" + flvid + "&outall=true"),
        q = encodeURIComponent("854d6fae5ee42911677c739ee1734486"),
        h = encodeURIComponent("\u7206\u7c73\u82b1\u7f51"),
        n = encodeURIComponent("http://www.pomoho.com/"),
        s = encodeURIComponent(pic);
        $('<span class="label">\u8f6c\u8d34\u5230\uff1a</span><span class="icos"><a id="QQ" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + b + "&title=" + a + '&charset=utf-8" target="_blank" title="QQ\u7a7a\u95f4">\u8f6c\u8d34\u81f3QQ\u7a7a\u95f4</a><a id="wuyicom" href="http://share.51.com/share/out_share_video.php?vaddr=' + e + "&title=" + a + '&from=pomoho&charset=utf-8" target="_blank" title="51\u4ea4\u53cb\u793e\u533a">\u8f6c\u8d34\u81f351\u4ea4\u53cb\u793e\u533a</a><a id="renren" href="http://share.renren.com/share/buttonshare.do?link=' + b + "&title=" + a + '" target="_blank" title="\u8f6c\u8d34\u81f3\u4eba\u4eba\u7f51">\u8f6c\u8d34\u81f3\u4eba\u4eba\u7f51</a><a id="kaixin" href="http://www.kaixin001.com/repaste/share.php?rurl=' + b + "&rcontent=" + b + "&rtitle=" + a + '" target="_blank" title="\u8f6c\u8d34\u81f3\u5f00\u5fc3\u7f51">\u8f6c\u8d34\u81f3\u5f00\u5fc3\u7f51</a><a onclick="postToWb();" class="tmblog"></a><a id="sina" href="http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_pomoho_weibo&url=' + b + "&title=" + a + "&source=" + h + "&sourceUrl=" + n + "&appkey=1854178289&pic=" + s + '" target="_blank" title="\u8f6c\u8d34\u81f3\u65b0\u6d6a\u5fae\u535a">\u8f6c\u8d34\u81f3\u65b0\u6d6a\u5fae\u535a</a><a id="itieba" href="" onclick="Pui.space.share(\'' + b + "','" + a + "','" + d + '\');return false;" title="\u8f6c\u8d34\u81f3i\u8d34\u5427">\u8f6c\u8d34\u81f3i\u8d34\u5427</a><a id="feixin" href="http://space.fetion.com.cn/api/share?source=' + h + "&url=" + b + "&title=" + a + '" target="_blank" title="\u8f6c\u53d1\u81f3\u98de\u4fe1\u7a7a\u95f4">\u8f6c\u53d1\u81f3\u98de\u4fe1\u7a7a\u95f4</a><a id="msn" href="http://profile.live.com/badge/?url=' + b + "&title=" + a + "&description=" + c + "&screenshot=" + s + "&swfurl=" + f + '&height=490&width=580&ctype=flash" target="_blank" title="\u8f6c\u8d34\u81f3MSN">\u8f6c\u8d34\u81f3MSN</a><a id="qiyi" href="http://t.qiyi.com/share/share.php?url=' + b + "&appkey=" + q + "&pic=" + s + "&title=" + a + '&charset=utf-8" target="_blank" title="\u8f6c\u5e16\u81f3\u5947\u8c08">\u8f6c\u5e16\u81f3\u5947\u8c08</a>' + ('<span style="float:left;margin-top:-4px;position:relative;"><iframe scrolling="no" frameborder="0" allowtransparency="true" src="http://www.connect.renren.com/like?url=' + b + '&showfaces=false&logostyle=single" marginwidth="0" marginheight="0" style="width: 60px;height: 30px;"></iframe></span>') + '<span style="float:left;margin-top:-4px;position:relative;"><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F744088371&type=button_num&width=400&height=30" allowtransparency="true" scrolling="no" border="0" frameborder="0" marginwidth="0" marginheight="0" style="width: 110px;height: 30px;border:none;"></iframe></span><span style="float:left;margin-top:-4px;position:relative;"><iframe scrolling="no" style="width: 64px; height: 22px;border:0" src="http://static01.pomoho.com/sinacon/sinaConcern.html" marginheight="0" marginwidth="0" border="0" allowtransparency="true"></iframe></span></span>').appendTo(".video_info .handle").hover(function () {
            $(".video_info .handle,#VideoPlayer .video_info").css("overflow", "visible")
        },
        function () {
            $(".video_info .handle,#VideoPlayer .video_info").css("overflow", "hidden")
        })
    },
    zz: function () {
        var a = "";
        encodeURIComponent($("title").html().replace(/(^\s*)|(\s*$)/g, ""));
        var b = "http://home.pomoho.com/" + _space_user.username + "/" + flvid,
        c = "http://resources.pomoho.com/swf/out_player.swf?flvid=" + flvid + "&outall=true";
        encodeURIComponent("\u7206\u7c73\u82b1\u7f51");
        encodeURIComponent("http://www.pomoho.com/");
        var d = "";
        d += '<div id="ZZ" style="display:none;">';
        d += ' <div class="s1">';
        a = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="480" height="396" id="object"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="' + c + '" /><embed src="' + c + '" quality="high" width="480" height="396" allowScriptAccess="always"/></object>';
        d += String(window.location).match(/http:\/\/video\.dvod.*/) ? ' \u6b64\u8282\u76ee\u5730\u5740\uff08URL\uff09<br /><input type="text" class="url" value="http://video.dvod.com.cn/news/' + flvid + '.shtml" /><br />' : ' \u6b64\u8282\u76ee\u5730\u5740\uff08URL\uff09<br /><input type="text" class="url" value="' + b + '" /><br />';
        d += ' \u628a\u64ad\u653e\u5668\u663e\u793a\u5230\u4e2a\u4eba\u7a7a\u95f4\u6216Blog<br /><input type="text" class="url" value="' + c + '" /><br />';
        d += ' HTML\u4ee3\u7801,\u9002\u7528\u4e8e\u4e2a\u4eba\u7a7a\u95f4\uff08\u6216\u5176\u4ed6\u7c7b\u578b\u7684Blog\uff09<br /><input type="text" class="url" value="" /><br />';
        d += ' BBS\u4ee3\u7801<br /><input type="text" class="url" value="[flash]' + c + '[/flash]" />';
        d += " </div>";
        d += ' <p><a href="" onclick="$(\'#ZZ\').slideUp();return false;">\u5173\u95ed</a></p>';
        d += "</div>";
        $(d).appendTo($("#Space")).css({
            "z-index": "9999",
            top: "552px",
            left: "16px"
        });
        $("#VideoPlayer #Handle").find('.s1[title="\u8f6c\u8d34\u8be5\u89c6\u9891"]').click(function () {
            $("#ZZ").slideToggle("slow");
            this.blur();
            return false
        });
        $("#ZZ .url").eq(2).attr("value", a).end().hover(function () {
            $(this).select()
        },
        function () {
            $(this).blur()
        })
    },
    hideComment: function () {
        String(window.location).match(/http:\/\/home.*/);
        $("#Comment .mDocument").filter(":gt(19)").hide();
        $("#Comment h3 span.count").html(20)
    },
    relatedSearch: function () {
        function a() {
            var c = _keywords.root_key;
            $("#SearchForm #SearchInput").val(c).css("color", "#999").focus(function () {
                var d = $(this);
                d.val() == c && d.val("").css("color", "#000")
            }).blur(function () {
                var d = $(this);
                $.trim(d.val()) == "" && d.val(c).css("color", "#999")
            })
        }
        var b = document.referrer.toString();
        b.indexOf("baidu.com") != -1 || b.indexOf("google.com") != -1 || b.indexOf("sogou.com") != -1 || b.indexOf("soso.com") != -1 || b.indexOf("search.pomoho.com") != -1 ? Pui.ajaxLoad("GET", "http://home.pomoho.com/do/interfaces/relatedwords.aspx", "videoid=" + flvid + "&fromurl=" + document.referrer.toString().replace("?", "&"), "", ".loading",
        function () {
            if (parseInt(_getDATA) != -1) {
                $(_getDATA).appendTo($("#VideoPlayer"));
                a()
            }
        }) : Pui.ajaxLoad("GET", "http://home.pomoho.com/do/interfaces/relatedwords.aspx", "videoid=" + flvid + "&fromurl=", "", ".loading",
        function () {
            if (parseInt(_getDATA) != -1) {
                $(_getDATA).appendTo($("#VideoPlayer"));
                a()
            }
        })
    },
    hotVideoList: function () {
        if (!(typeof hotVideoTopJson == "undefined" || !(hotVideoTopJson instanceof Array))) if (!(typeof hotVideoJson == "undefined" || !(hotVideoJson instanceof Array))) {
            Pui.space.addVideo(hotVideoJson, "hotvideo", "\u63a8\u8350\u89c6\u9891", "", "#recommendVideo", 0, 6, "P3S04", false);
            Pui.space.addVideo(hotVideoTopJson, "popvideo", "\u6628\u65e5\u6392\u884c", "", "#yesterdayTopVideo", 0, 3, "P3P39", true)
        }
    },
    addVideo: function (a, b, c, d, e, f, h, n, s) {
        typeof a == "object" &&
        function () {
            if (!(a == null || a.length == 0)) {
                var q = a.length,
                t = document.createElement("div"),
                p = "";
                p = "";
                if (d == null || d == "") d = "http://www.pomoho.com/" + a[0].channelText + "/" + a[0].channelText + ",video,24hour,1";
                for (var m = 0; m < q; m++) {
                    p = s ? a[m].spaceURL + "/" + a[m].videoID + "?" + n : "http://search.pomoho.com/videosearch.aspx?_keyword=" + encodeURIComponent(a[m].videoName) + "&_f=" + n + "&vid=" + a[m].videoID;
                    p = '<ul><li class="link_mask"><a target="_blank" title="' + a[m].videoName + '" href="' + p + '"></a></li><li class="vimg"><a target="_blank" href="' + p + '"><img src="' + a[m].imgURL + '" alt="' + a[m].videoName + '" /></a></li><li class="vtitle"><a target="_blank" title="' + a[m].videoName + '" href="' + p + '">' + a[m].videoName + "</a></li></ul>";
                    if (m % h == 0) var v = document.createElement("div");
                    $(v).attr("class", "row").append($(p)).appendTo($(t).attr("class", "showblock"))
                }
                q = $('<div class="block ' + b + '" id="' + b + '">').append('<h3><span class="title">' + c + '</span><span class="more"><a href="' + d + '">\u66f4\u591a</a></span></h3>').append($(t));
                switch (f) {
                    case 0:
                        q.appendTo($(e));
                        break;
                    case 1:
                        q.prependTo($(e));
                        break;
                    case 2:
                        q.insertBefore($(e));
                        break;
                    case 3:
                        q.insertAfter($(e))
                }
            }
        } (a)
    },
    relateVideo: function () {
        (function () {
            if ($("#relateVideo").length > 0) {
                var a = videoTitle;
                $.getJSON("http://search.pomoho.com/getrelatvevideojson.aspx?jsoncallback=?", {
                    count: 14,
                    videoid: typeof flvid == "undefined" ? 5610450 : flvid,
                    title: a
                },
                function (b) {
                    if (b != null) {
                        b = Pui.space.showVideoList(b, decodeURIComponent(a), "\u76f8\u5173\u89c6\u9891", "P3P32", 9);
                        b != "" && $("#relateVideo").append(b)
                    }
                })
            }
        })()
    },
    showVideoList: function (a, b, c, d, e) {
        if (typeof a == "object" && !(a instanceof Array)) a = a.videoList instanceof Array ? a.videoList : [];
        if (a.length == 0) return "";
        e = e || 9;
        b = b || a[0].videoName;
        var f = encodeURIComponent(b),
        h = '<div class="block videolist">';
        h += '<h3><span class="title">' + c + "</span>";
        h += '<span class="more"><a target="_blank" href="http://search.pomoho.com/videosearch.aspx?_keyword=' + f + '&_f=P3SO3" id="aHrefVideo" target="_blank">\u66f4\u591a</a></span></h3>';
        c = "," + b + ",";
        h += '<div class="showblock">';
        h += "<ul>";
        for (f = 0; f < a.length && 0 < e; f++) if (!(c.indexOf("," + a[f].videoName + ",") > -1)) {
            e--;
            c += a[f].videoName + ",";
            h += "<li>";
            h += '<a href="http://home.pomoho.com/' + a[f].spaceURL + "/" + a[f].videoID + "?" + d + '" target="_blank" title="' + a[f].videoName + '"><img src="' + a[f].imgURL + '" alt="' + a[f].videoName + '"/></a>';
            h += '<p><a href="http://home.pomoho.com/' + a[f].spaceURL + "/" + a[f].videoID + "?" + d + '" target="_blank" title="' + a[f].videoName + '">' + a[f].videoName + "</a></p>";
            h += "</li>"
        }
        h += "</ul>";
        h += "</div>";
        h += "</div>";
        if (c != "," + b + ",") return h;
        return ""
    },
    userRelateKeyWords: function (a, b, c, d, e) {
        if (a == null || a.length == 0) return "";
        e = e || 9;
        var f = ["color:#666666;", "color:#0000ff;"],
        h = encodeURIComponent(b || a[0].keyWord);
        b = '<div class="block videolist">';
        b += '<h3><span class="title">' + c + "</span>";
        b += '<span class="more"><a target="_blank" href="http://search.pomoho.com/videosearch.aspx?_keyword=' + h + '&_f=P3SO3" id="aHrefVideo" target="_blank">\u66f4\u591a</a></span></h3>';
        b += '<div class="showblock antistop">';
        b += "<p>";
        for (c = 0; c < a.length && 0 < e; c++) b += '<a href="http://search.pomoho.com/videosearch.aspx?_keyword=' + encodeURIComponent(a[c].keyWord) + "&_f=" + d + '" title="' + a[c].keyWord + '" target="_blank" style="' + f[Math.floor(Math.random() * f.length)] + '">' + a[c].keyWord + "</a>";
        b += "</p>";
        b += "</div>";
        b += "</div>";
        return b
    },
    userRelateVideo: function () {
        function a(b, c) {
            if (b == null || b == "" || b.lastIndexOf("?") == -1) return "";
            if (c == null || c == "") return "";
            var d = b.lastIndexOf("?"),
            e = b.substr(d),
            f = c.lastIndexOf("=") == c.length - 1 ? c : c + "=";
            d = e.indexOf(f);
            if (d > -1) {
                d += f.length;
                f = e.indexOf("&", d);
                e = e.substr(d);
                if (f > d) e = e.substr(0, f - d);
                return e
            }
            return ""
        }
        $("#userRelateVideo").length == 0 && $("<div>").attr({
            id: "userRelateVideo"
        }).prependTo($("#Bar"));
        Pui.LazyLoad._initialize($("#userRelateVideo")[0]);
        Pui.LazyLoad.load(function () {
            var b = a(document.referrer, "word");
            if (b == "") {
                b = unescape(Pui.space.cookie("userPlayListTagTitle"));
                if (b == null || b == "null" || b == "") return "";
                b = eval("(" + b + ")");
                if (typeof b != "object") return "";
                b = Pui.space.userRelateKeyWords(b, null, "\u4f60\u53ef\u80fd\u8fd8\u4f1a\u559c\u6b22", "p3S05", 10);
                b != "" && $($("#userRelateVideo")[0]).append(b)
            } else $.getJSON("http://search.pomoho.com/getrelatvevideojson.aspx?jsoncallback=?", {
                count: 9,
                videoid: flvid,
                title: b,
                encode: "gb2312"
            },
            function (c) {
                Pui.LazyLoad.testAlert("json.length=" + c.length);
                if (c != null && c.videoList.length > 0) {
                    var d = c.videoTitle,
                    e = Pui.space.cookie("userPlayListTagTitle");
                    d = escape(d);
                    var f = '{"keyWord":"' + d + '"}';
                    if (e != null && e != "") {
                        e = eval("(" + e + ")");
                        if (e instanceof Array) for (var h = 0; h < e.length && h < 10; h++) if (e[h].keyWord != d) f += ',{"keyWord":"' + e[h].keyWord + '"}'
                    }
                    e = "[" + f + "]";
                    Pui.space.cookie("userPlayListTagTitle", e, {
                        expires: 365,
                        domain: ".pomoho.com"
                    });
                    c = Pui.space.showVideoList(c.videoList, null, "\u4f60\u53ef\u80fd\u8fd8\u4f1a\u559c\u6b22", "p3p05", 6);
                    c != "" && $($("#userRelateVideo")[0]).append(c)
                }
            })
        })
    },
    relateKeyCallback: function () {
        if (!(typeof arrRelateKey == "undefined" || !(arrRelateKey instanceof Array))) {
            var a = arrRelateKey;
            $("#div_relatedSearch").hide();
            var b = '<h3><span class="title">\u76f8\u5173\u641c\u7d22</span></h3><div class="showblock"><ul>',
            c = 1;
            $(a).each(function (d) {
                if ($(this)[0]) {
                    if (d < 4) {
                        d = '<a href="http://search.pomoho.com/videosearch.aspx?_keyword=' + $(this)[0].enkeyName + '&_f=P3S02">' + decodeURIComponent($(this)[0].enkeyName) + "</a>&nbsp;";
                        $(".v_tag").html($(".v_tag").html() + d)
                    }
                    $(this)[0].data != "" && $(this)[0].data != null && $($(this)[0].data).each(function () {
                        b += '<li><a href="http://search.pomoho.com/videosearch.aspx?_keyword=' + $(this)[0].enkey + '&_f=P3S02" target="_blank" title="' + decodeURIComponent($(this)[0].enkey) + '">' + decodeURIComponent($(this)[0].enkey) + "</a></li>";
                        c++
                    })
                }
            });
            b += "</ul></div>";
            $("#div_relatedSearch").html(b);
            $("#div_relatedSearch").show()
        }
    },
    cookie: function (a, b, c) {
        if (typeof b != "undefined") {
            c = c || {};
            if (b === null) {
                b = "";
                c.expires = -1
            }
            var d = "";
            if (c.expires && (typeof c.expires == "number" || c.expires.toUTCString)) {
                if (typeof c.expires == "number") {
                    d = new Date;
                    d.setTime(d.getTime() + c.expires * 24 * 60 * 60 * 1E3)
                } else d = c.expires;
                d = "; expires=" + d.toUTCString()
            }
            document.cookie = [a, "=", b, d, c.path ? "; path=" + c.path : "; path=/", c.domain ? "; domain=" + c.domain : "", c.secure ? "; secure" : ""].join("")
        } else {
            b = null;
            if (document.cookie && document.cookie != "") {
                c = document.cookie.split(";");
                for (d = 0; d < c.length; d++) {
                    var e = jQuery.trim(c[d]);
                    if (e.substring(0, a.length + 1) == a + "=") {
                        b = e.substring(a.length + 1);
                        break
                    }
                }
            }
            return b
        }
    },
    playlist: function (a) {
        var b = a + 1,
        c = $("#VideoBox .row").length,
        d = 1 + c,
        e = -1,
        f = true,
        h = true;
        $("#ListSwitch .r").addClass("r_b").attr("title", "\u5411\u53f3\u7ffb");
        $("#ListSwitch .l").addClass("l_b").attr("title", "\u5411\u5de6\u7ffb");
        $("#ListSwitch .playlist").find(".l").click(function () {
            b < 2 && f ? n(false) : m();
            return false
        });
        $("#ListSwitch .playlist").find(".r").click(function () {
            b >= c && h ? n(true) : p();
            return false
        });
        var n = function (k) {
            var i = 0,
            l = null;
            i = k ? d++ : e--;
            $.getJSON("/play2/interface/getuservideolist.ashx?jsoncallback=?", {
                userid: _space_user.uid,
                videoid: flvid,
                page: i,
                pagesize: 9,
                zl: programID,
                type: programID > 0 ? "zl" : "user"
            },
            function (g) {
                if (g != null) {
                    l = s(g.d);
                    var u = l != null;
                    g = g.d;
                    if (g == null || g.UserVideos == null || g.UserVideos.length == 0) g = false;
                    else {
                        var x = _space_user.username;
                        for (var o = "<div class='row'>",
                        r = {},
                        w = 0; w < g.UserVideos.length; w++) {
                            r = g.UserVideos[w];
                            o += "<ul>";
                            o += '<li class="vimg">';
                            o += '<a href="http://home.pomoho.com/' + x + "/" + r.VideoId + '?P3P31">';
                            o += '<img src="' + r.Pic + '" title="' + r.Title + '" alt="' + r.Title + '"></a>';
                            o += "</li>";
                            o += '<li class="vtitle">';
                            o += '<a title="' + r.Title + '" href="http://home.pomoho.com/' + x + "/" + r.VideoId + '?P3P31">' + r.Title + "</a>";
                            o += "</li>";
                            o += "</ul>"
                        }
                        o += "</div>";
                        g.PageIndex > 0 ? $("#VideoBox").append(o) : $("#VideoBox").prepend(o);
                        g = true
                    }
                    if (u & g) {
                        c = $("#VideoBox .row").length;
                        l()
                    }
                }
            });
            return false
        },
        s = function (k) {
            if (k == null) return null;
            var i = k.PageSize == k.PageCount;
            if (k.PageIndex > 0) {
                h = i;
                return function () {
                    p()
                }
            } else {
                f = i;
                return function () {
                    b++;
                    m()
                }
            }
        },
        q = function (k) {
            var i = $("#VideoBox div.row");
            if (!(k && b - 2 > 0 && b < i.length - 1)) {
                var l = k ? i.length - 1 : 0;
                l = i.eq(l).find("ul");
                if (l.length != 9) {
                    var g = 9 - l.length;
                    l = k ? i.length - 2 : 1;
                    l = $("#VideoBox div.row:eq(" + l + ") ul");
                    if (k) {
                        k = $("#VideoBox div.row:last");
                        for (i = 0; i < g; i++) l.eq(i).clone().prependTo(k)
                    } else {
                        k = $("#VideoBox div.row:first");
                        for (i = 0; i < g; i++) l.eq(i).clone().appendTo(k)
                    }
                }
            }
        },
        t = function () {
            !f && b == 1 ? $("#ListSwitch .l").removeClass("l_b").attr("title", "\u5de6\u8fb9\u6ca1\u6709\u4e86") : $("#ListSwitch .l").addClass("l_b").attr("title", "\u5411\u5de6\u7ffb"); !h && $("#VideoBox div.row").length == b ? $("#ListSwitch .r").removeClass("r_b").attr("title", "\u53f3\u8fb9\u6ca1\u6709\u4e86") : $("#ListSwitch .r").addClass("r_b").attr("title", "\u5411\u53f3\u7ffb");
            setTimeout(function () {
                v()
            },
            600);
            return false
        },
        p = function () {
            if (b <= c - 1) {
                q(true);
                $("#VideoBox").animate({
                    left: -(900 * b)
                },
                400);
                b++
            }
            t();
            return false
        },
        m = function () {
            if (b >= 2) {
                q(false);
                $("#VideoBox").animate({
                    left: -(900 * (b - 2))
                },
                500);
                b--
            }
            t();
            return false
        },
        v = function (k) {
            var i = $("#VideoBox div.row");
            if (i.length != 0) {
                var l = 0,
                g = parseInt($("#VideoBox").css("left"));
                if (!isNaN(g) && g < 0) l = -(g / 900);
                g = i.eq(l).children("ul");
                if (g.length != 0) {
                    i = /http:\/\/(\w+.)+\/\w+\/(\d+)(\?\w+)*/;
                    l = g.eq(0).find("a").eq(0).attr("href");
                    g = g.eq(g.length - 1).find("a").eq(0).attr("href");
                    g = i.exec(g);
                    i = i.exec(l);
                    g == null || i == null || Pui.space.cookie("playlist", '{"Start":' + g[2] + ',"End":' + i[2] + ',"SpaceURL":"' + _space_user.username + '"}', {
                        expires: k || 1,
                        domain: ".pomoho.com"
                    })
                }
            }
        }; (function () {
            var k = "";
            if ($("#VideoBox ul[id='current_" + flvid + "']").length > 0) for (var i = $("#VideoBox ul"), l = false, g = {},
            u = 0; u < i.length; u++) {
                g = i.eq(u);
                if (l) {
                    k = g.find("a").attr("href");
                    break
                }
                l = g.attr("id") != "" ? true : false
            }
            if (k == "") {
                if ($("#VideoBox ul:first a:first").length == 0) return;
                k = $("#VideoBox ul:first a:first").attr("href")
            }
            window.playNext = function () {
                location.href = k
            }
        })();
        setTimeout(function () {
            v()
        },
        400)
    },
    VideoWelter: function () {
        var a = $(".playlist #VideoBox");
        _self = this;
        rowN = $(".playlist #VideoBox .row").length;
        var b = "current_" + flvid,
        c = false;
        a.find(".row ul").each(function () {
            var d = $(this);
            if (d.attr("id") == b) {
                d.addClass("ac");
                d = a.find(".row").index(d.parent()[0]);
                a.animate({
                    left: -(900 * d)
                },
                500);
                _self.playlist(d);
                c = true
            }
        });
        c || _self.playlist(0)
    }
};
Pui.searching = {
    init: function () {
        Pui.searching.showHotKeywords();
        this.Main();
        $("#SearchForm").submit(function () {
            Pui.searching.DoSearch(this);
            return false
        })
    },
    Main: function () {
        this.SelectEvents();
        this.showMore()
    },
    OnLoad: function () {
        $("#SearchInput").val("\u641c\u4e00\u4e0b").focus(function () {
            $(this).val() == "\u641c\u4e00\u4e0b" && $(this).val("")
        }).blur(function () {
            $(this).val() == "" && $(this).val("\u641c\u4e00\u4e0b")
        })
    },
    SelectEvents: function () {
        $("body").click(function () {
            $("#SelDiag").css("display") != "none" && $("#SelDiag").slideUp("fast")
        });
        $(".btnSel a").click(function () {
            $("#SelDiag").css("display") != "none" ? $("#SelDiag").slideUp("fast") : $("#SelDiag").slideDown("fast");
            return false
        });
        $("#SelDiag1").click(function () {
            Pui.searching.SelectDiag("video", $(this));
            this.blur();
            return false
        });
        $("#SelDiag2").click(function () {
            Pui.searching.SelectDiag("user", $(this));
            this.blur();
            return false
        });
        $("#SelDiag3").click(function () {
            Pui.searching.SelectDiag("subject", $(this));
            this.blur();
            return false
        })
    },
    SelectDiag: function (a, b) {
        $("#SearchType").val(a);
        $("#SelDiag").css("display", "none");
        $("#Selected").text($(b).text());
        $("#SearchT").focus()
    },
    showMore: function () {
        $("#Menu li:last a").click(function () {
            if ($(".morelist").css("display") != "none") {
                $(".morelist").css("display", "none");
                $("#Menu li:last a strong").html("\u25bc")
            } else {
                $(".morelist").css("display", "block");
                $("#Menu li:last a strong").html("\u25b2")
            }
            return false
        });
        $("body").click(function () {
            $(".morelist").css("display", "none");
            $(".morelist").css("display", "none");
            $("#Menu li:last a strong").html("\u25bc")
        })
    },
    showHotKeywords: function () {
        var a = ["%e8%b5%9b%e5%b0%94%e5%8f%b7", "%e5%b9%bf%e5%b7%9e%e5%9c%b0%e9%93%81%e5%85%8d%e8%b4%b9", "%e5%8d%b0%e5%b0%bc%e7%81%ab%e5%b1%b1"],
        b = document.createElement("span");
        b.className = "hot_keywords";
        b = $(b);
        for (var c = 0,
        d = a.length; c < d; c++) b.append('<a href="' + ("http://search.pomoho.com/videosearch.aspx?_keyword=" + a[c]) + '&_f=x0s01" target="_blank">' + decodeURIComponent(a[c]) + "</a>");
        b.appendTo(".header2 #phead")
    },
    DoSearch: function (a) {
        var b = $(a).find("#SearchInput").val();
        if ($.trim(b) == "" || b == "\u641c\u4e00\u4e0b") {
            alert("\u5bf9\u4e0d\u8d77\uff0c\u5173\u952e\u8bcd\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
            $("#SearchInput").focus()
        } else {
            var c = a.searchDomain,
            d = "http://search.pomoho.com";
            if (c != undefined && c.value != "") d = c.value;
            b = encodeURIComponent(b);
            a = d + "/" + a.SearchType.value + "search.aspx?_keyword=" + b + "&_f=p0s04";
            if (document.location.hostname.indexOf("search.pomoho.com") != -1) document.location.href = a;
            else window.open(a, "search")
        }
        return false
    },
    Search: function (a) {
        if (a != "") {
            a = "http://search.pomoho.com/videosearch.aspx?_keyword=" + encodeURIComponent(a);
            if (document.location.hostname.indexOf("search.pomoho.com") != -1) document.location.href = a;
            else window.open(a, "search")
        }
        return false
    }
};
Pui.LazyLoad = {
    lazyloadThis: null,
    _initialize: function (a) {
        lazyloadThis = Pui.LazyLoad;
        lazyloadThis._timer = null;
        lazyloadThis.isFinish = false;
        lazyloadThis._lock = false;
        lazyloadThis.delay = 1E3;
        lazyloadThis.windowObj = lazyloadThis.getWindowRect();
        lazyloadThis.scrollObj = lazyloadThis.getScroll();
        lazyloadThis.containerObj = lazyloadThis.getRect(a)
    },
    load: function (a) {
        if (!(a == null || typeof a != "function")) {
            $(window).scroll(function () {
                lazyloadThis.scrollObj = lazyloadThis.getScroll();
                if (lazyloadThis.scrollObj.top + lazyloadThis.windowObj.bottom > lazyloadThis.containerObj.top) {
                    lazyloadThis._delay(a);
                    lazyloadThis.isFinish = true
                }
                return false
            });
            $(window).scroll()
        }
    },
    getScroll: function () {
        var a, b, c, d;
        if (document.documentElement && document.documentElement.scrollTop) {
            a = document.documentElement.scrollTop;
            b = document.documentElement.scrollLeft;
            c = document.documentElement.scrollWidth;
            d = document.documentElement.scrollHeight
        } else if (document.body) {
            a = document.body.scrollTop;
            b = document.body.scrollLeft;
            c = document.body.scrollWidth;
            d = document.body.scrollHeight
        }
        return {
            top: a,
            left: b,
            right: c,
            bottom: d
        }
    },
    getWindowRect: function () {
        return "innerHeight" in window ? {
            left: 0,
            right: window.innerWidth,
            top: 0,
            bottom: window.innerHeight
        } : {
            left: 0,
            right: document.documentElement.offsetWidth,
            top: 0,
            bottom: document.documentElement.offsetHeight
        }
    },
    getRect: function (a) {
        for (var b = a,
        c = 0,
        d = 0; b; ) {
            c += b.offsetLeft;
            d += b.offsetTop;
            b = b.offsetParent
        }
        return {
            left: c,
            right: c + a.offsetWidth,
            top: d,
            bottom: d + a.offsetHeight
        }
    },
    _delay: function (a) {
        clearTimeout(lazyloadThis._timer);
        if (!lazyloadThis.isFinish) {
            var b = this,
            c = lazyloadThis.delay;
            if (lazyloadThis._lock) lazyloadThis._timer = setTimeout(function () {
                b._delay(a)
            },
            c);
            else {
                lazyloadThis._lock = true;
                a();
                lazyloadThis.testAlert("runed");
                setTimeout(function () {
                    b._lock = false
                },
                c)
            }
        }
    },
    testAlert: function (a) {
        location.href.indexOf("localhost") > -1 && alert(a)
    }
};
Pui.space.video = {
    init: function () {
        PUB.Init();
        Pui.space.init();
        Pui.searching.init()
    }
};
function SendCallBack(a, b) {
    PUB.SendCallBack.call(this, a, b)
};
$(document).ready(function () {
    if (PUB.isLogin == true) PUB.GetAction(flvid);
    $("#VideoBox img").lazyload({
        placeholder: "http://static01.pomoho.com/img/home/grey.gif",
        effect: "fadeIn"
    });

    $("#yesterdayTopVideo").lazyload({
        effect: "fadeIn",
        callback: function () {
            getPlayVideoOrder("0", function (data) {
                $("#yesterdayTopVideo").html(data);
                $("#yesterdayTopVideo img").lazyload({
                    placeholder: "http://static01.pomoho.com/img/home/grey.gif",
                    effect: "fadeIn"
                });
            });
        }
    });
    $("#recommendVideo").lazyload({
        effect: "fadeIn",
        callback: function () {
            getPlayVideoOrder("1", function (data) {
                $("#recommendVideo").html(data);
                $("#recommendVideo img").lazyload({
                    placeholder: "http://static01.pomoho.com/img/home/grey.gif",
                    effect: "fadeIn"
                });
            });
        }
    });
});
function getPlayVideoOrder(type, callback) {
    var cId = (type == "0") ? "" : channelId;
    var cName = (type == "0") ? "" : channelEngName;
    var url = "/interface/" + type + "_" + cId + "_" + cName;
    $.ajax({
        type: "Get",
        url: url,
        dataType: "text",
        cache: true,
        timeout: 300000,
        beforeSend: function () {
        },
        success: function (data) {
            callback(data);
        },
        error: function () {
        }
    });
};
function postToWb() {
    var a = encodeURI(document.title);
    var b = encodeURIComponent(document.location);
    var c = encodeURI("6fecfd1d14b14aaeba7982c69e96d0d3");
    var d = encodeURI(pic);
    var e = window.location.href;
    var f = 'http://v.t.qq.com/share/share.php?url=' + b + '&appkey=' + c + '&site=' + e + '&pic=' + d + '&title=' + a;
    window.open(f, '', 'width=700,height=680,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,location=yes,resizable=no,status=no')
};
(function ($) {
    $.fn.lazyload = function (options) {
        var settings = {
            threshold: 0,
            failurelimit: 0,
            event: "scroll",
            effect: "show",
            container: window
        };
        if (options) {
            $.extend(settings, options)
        }
        var elements = this;
        if ("scroll" == settings.event) {
            $(settings.container).bind("scroll",
            function (event) {
                var counter = 0;
                elements.each(function () {
                    if (!$.belowthefold(this, settings) && !$.rightoffold(this, settings)) {
                        $(this).trigger("appear");
                    } else {
                        if (counter++ > settings.failurelimit) {
                            return false
                        }
                    }
                });
                var temp = $.grep(elements,
                function (element) {
                    return !element.loaded
                });
                elements = $(temp)
            })
        }
        return this.each(function () {
            var self = this;
            if ("scroll" != settings.event || $.belowthefold(self, settings) || $.rightoffold(self, settings)) {
                if (settings.placeholder) {
                    $(self).attr("src", settings.placeholder);
                }
                self.loaded = false
            } else {
                self.loaded = true;
                if (settings.callback) {
                    settings.callback();
                } else {
                    $(self).attr("src", $(self).attr("original"));
                }
            }
            $(self).one("appear",
            function () {
                if (!this.loaded) {
                    if (settings.callback) {
                        settings.callback();
                    } else {
                        $("<img />").bind("load",
                        function () {
                            $(self).hide().attr("src", $(self).attr("original"))[settings.effect](settings.effectspeed);
                            self.loaded = true
                        }).attr("src", $(self).attr("original"))
                    }
                }
            });
            if ("scroll" != settings.event) {
                $(self).bind(settings.event,
                function (event) {
                    if (!self.loaded) {
                        $(self).trigger("appear")
                    }
                })
            }
        })
    };
    $.belowthefold = function (element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).height() + $(window).scrollTop()
        } else {
            var fold = $(settings.container).offset().top + $(settings.container).height()
        }
        return fold <= $(element).offset().top - settings.threshold
    };
    $.rightoffold = function (element, settings) {
        if (settings.container === undefined || settings.container === window) {
            var fold = $(window).width() + $(window).scrollLeft()
        } else {
            var fold = $(settings.container).offset().left + $(settings.container).width()
        }
        return fold <= $(element).offset().left - settings.threshold
    };
    $.extend($.expr[':'], {
        "below-the-fold": "$.belowthefold(a, {threshold : 0, container: window})",
        "above-the-fold": "!$.belowthefold(a, {threshold : 0, container: window})",
        "right-of-fold": "$.rightoffold(a, {threshold : 0, container: window})",
        "left-of-fold": "!$.rightoffold(a, {threshold : 0, container: window})"
    })
})(jQuery);
